XMPP is a protocol based on the Extensible Markup Language (XML). It is used for instant messaging (IM) and online detection. This protocol may eventually allow Internet users to send instant messages to anyone else on the Internet. XMPP is used to implement the push function of Android. XMPP is a real-time communication protocol.
XMPP is a protocol used for instant communication. The process of using XMPP is similar to that of using QQ. The process is divided into three steps:
1. Connect to the
())); startActivityForResult(intent, REQUEST_CODE);}@Overrideprotected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE) { if (Settings.canDrawOverlays(this)) { Log.i(LOGTAG, "onActivityResult granted"); } }}The above code needs to be aware that
To Settings.ACTION_MANAGE_OVERLAY_PERMISSION start an implicit intent with an action
In the client, we find the program entry in the Androidmanifest.xml file, which is the following demoappactivity class ,The main code in this class is as followsServiceManager ServiceManager = Newservicemanager (this);Servicemanager.setnotificationicon (r.drawable.notification);Servicemanager.startservice ();Along the way, there is a call to the Xmppmanager class in the Notificationservice (Xmppmanager.connect ();), and the Xmppmanager class is the class that the client is more important, and th
);}@Overrideprotected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE) { if (Settings.canDrawOverlays(this)) { Log.i(LOGTAG, "onActivityResult granted"); } }}The above code needs to be aware that
To Settings.ACTION_MANAGE_OVERLAY_PERMISSION start an implicit intent with an action
Use "package:"+ getPackageName() the package name in
mainlooper = Looper.getmainlooper ();
LOG.I (LogTag, "Isinmainthread mylooper=" + mylooper
+ "; mainlooper=" + mainlooper);
return mylooper = = Mainlooper;
}
OK, then we run a test in the main thread and invoke the above method. Like we call this.
Copy Code code as follows:
LOG.I (LogTag, "Testinmainthread inmainthread=" + isinmainthread ());
OK, let's take a look
FFmpeg is a very powerful set of video audio processing libraries, however, the powerful features are generally unavoidable complex implementations, or more realistically, the "trouble" of the deployment and use of the processAbout "ffmpeg How to deploy" this is put in another article, the following into the topic:Both the Encoding encoder module and the decoding decoder module have init initialization method and resource free methodThe Init initialization method is mainly for the initialization
. If you are not sure how Java code implements the improvements, you can click on the Java code to write an Android app to achieve security PackageCom.example.obtaintouchicon;ImportJava.io.BufferedReader;Importjava.io.FileNotFoundException;Importjava.io.IOException;ImportJava.io.InputStream;ImportJava.io.InputStreamReader;Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.util.Log;ImportAndroid.webkit.JavascriptInterface;Importandroid.webkit.WebChromeClient;ImportAndroid.webkit.Web
();//start thread, Nativedaemonconnector implement Runnable interface, implement in Run//ADD ourself to the Watchdog monitors if enable D. if (watchdog_enable) {watchdog.getinstance (). Addmonitor (this); } }Two. Mountservice Receive socket:Above see constructs the nativedaemonconnector used to receive the socket message from the lower layer, first look at the structure: Nativedaemonconnector (inativedaemonconnectorcallbacks Callbacks, string socket, int responsequeuesiz
that calls the Foo::bar () function: 1 2 3 void Foo::bar () {4 // callstack::callstack (const char* LogTag, int32_t ignoredepth, int32_t maxDepth) 5 New CallStack ("Trace"1); 6 Delete t; 7 }CA little bit more trouble, need to call directly corkscrew/backtrace . In fact, C + + utils/Callstack is also used corkscrew/backtrace , just to make the package easier to use. We can refer to the CallStack.cpp code inside. The following example is
);} setrequestedorientation (Activityinfo.screen_orientation_landscape); Videowebview.setvisibility (View.gone); //If a view already exists, then immediately terminate and create a new if(Xcustomview! =NULL) {Callback.oncustomviewhidden (); return; } videoview.addview (view); Xcustomview=view; Xcustomviewcallback=callback; Videoview.setvisibility (view.visible); } @Override//the video playback exits full screen will be called Public voidOnhidecustomview () {if(Xcustomview = =NULL)//not
Before using Onsharedpreferencechangelistener, there is a small problem, that is, sometimes onsharedpreferencechangelistener is not triggered. Recently spent a little time studying, small do tidy up. This article will explain why the listener is not triggered, how to fix it, and some of the technical details implied therein.
Problem reappearance
Onsharedpreferencechangelistener is a listener for changes in sharedpreference files in Android. Usually we want to listen, and we will implement the
How to implement JavaScript and Java interactionIt is very convenient to implement Java and JS interaction. This usually takes only a few steps.
WebView Open JavaScript Script execution
WebView sets the interface for JavaScript calls.
The client and the Web side write code that calls each other.
#直接看示例代码:The Java code is as follows:Package Com.ccb.javascript;import Java.net.urisyntaxexception;import Android.annotation.suppresslint;import Android.annotation.targetapi;import
Android project is located --> ndk-build (cross-compilation command), refresh the project, and there will be one in libs/armeabi. so file, the file name is lib + hello (the Library name defined in mk), and an obj folder will be added in the project, mainly storing intermediate files
Step 5:Introduce function libraries in Java code
// Use a static code block to introduce the function library static {System. loadLibrary ("hello");} to Java code ");}
Step 6:
Public void method () {// call String s
--> ndk-build (cross-compilation command), refresh the project, and there will be one in libs/armeabi. so file, the file name is lib + hello (the Library name defined in mk), and an obj folder will be added in the project, mainly storing intermediate files
Step 5:Introduce function libraries in Java code
// Use a static code block to introduce the function library static {System. loadLibrary ("hello");} to Java code ");}
Step 6:
Public void method () {// call String str = helloFromC (); Toast.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.